package com.mq.conf;

import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;

public class ExpireMessage implements MessagePostProcessor {

    //过期剩余时间
    private final String ttl;

    //构造器
    public ExpireMessage(String ttl){
        this.ttl = ttl;
    }

    //设置过期时间
    @Override
    public Message postProcessMessage(Message message) throws AmqpException {
        message.getMessageProperties().setExpiration(ttl);
        return message;
    }
}
